#!/usr/bin/perl -w

##HACKABOT_HELP##
# Blame someone in the channel for the horrible things they did.
# !blame [something bad] | --add something bad
##HACKABOT_HELP##

use strict;
use Hackabot::Client;

my $hbc = Hackabot::Client->new;
my $msg = $hbc->readline;
my $nick = $hbc->sent_by;
my $chan = $hbc->channel;

if ($msg =~ /^--add\s+(.+)/) {
	chomp $1;
    $hbc->quote_add("blame", $1);
    print "send $nick: Successfully added\n";
}
elsif ($hbc->private) {
	print "send I blame you!!!\n";
}
else {
	 if ($msg eq "") {
		$msg = $hbc->quote_get("blame");
	}

	my @names = $hbc->names($chan);
	if (@names) {
		my $name = $names[int(rand(@names))];
		print "me blames $name for $msg.\n";
	}
}
